package com.example.timedormitoryDB;

import java.io.IOException;
import java.util.HashMap;

import android.location.Location;
import android.text.format.Time;

import com.example.clockDTO.Job;
import com.example.clockDTO.User;

public class TimeProvidereStub implements ItimeProvider{
	
/**
 * Method ClockIn
 * @param user, time, job, location
 * @throws Exception if null 
 * Process normally if !null
 */
	@Override
	public void clockIn(User username, Time time, Job jobID,
			Location location) throws Exception {
		//just validating null for now. Not sure where we can validate time clock in and clock out
		if(username.getUsername().equals(null))
		{
			throw new IOException("Null Username");
		}
		if(time.equals(null))
		{
			throw new IOException("Null Time");
		}
		if(jobID.equals(null))
		{
			throw new IOException("Null JobID");
		}
		if(location.equals(null))
		{
			throw new IOException("Null Location");
		}
	 
	}
	/**
	 * Method ClockOut
	 * @param user, time, job, location
	 * @throws Exception if null 
	 * Process normally if !null
	 */
	@Override
	public void clockOut(User username, Time time, Job jobID,
			Location location) throws Exception {
		//same thing here. I'm not sure if we even need this method
		if(username.getUsername().equals(null))
		{
			throw new IOException("Null Username");
		}
		if(time.equals(null))
		{
			throw new IOException("Null Time");
		}
		if(jobID.equals(null))
		{
			throw new IOException("Null JobID");
		}
		if(location.equals(null))
		{
			throw new IOException("Null Location");
		}	
	
	}
/**
 * Method fetchJob
 * @param Job
 * @return jobMap
 * return job based on JobID
 */
	@Override
	public HashMap<String, Job> fetchJob() {
		//I added this in in case you wanted to pull up a report to the UI
		
		HashMap<String, Job> jobMap = new HashMap<String,Job>();
		Job job = new Job();
		jobMap.put("0001", job);
		
		job.setJobID(0001);
		job.setName("UC Project");
		job.setDescription(".net Programming for UC website");
		job.setAddress("1234 Aven St. Cincinnati Ohio 45124");
		
		return jobMap;
	}
/**
 * method fetchUser
 * @param username
 * @return user
 * Should create and return a username if the name if TestUser
 * @throws Exception if username is not TestUser
 */
	@Override
	public User fetchUser(String username) throws Exception {
		//If we are doing login, this should be enough information that a user would need to enter
		if(username.contains("TestUser"))
		{
			User user = new User();
			user.setUsername("Test");
			user.setPassword("Test");
			user.setFirstName("Chavez");
			user.setLastName("Kattick");
			user.setPhoneNumber("513-283-9782");
			user.setEmail("ckattick@mail.uc.edu");
			
			return user;
		}
		else
		{
			throw new IOException("unable to fetch user");
		}
		
	}

}
